#@adminLayout()
#define main()
<div class="card">
    #@cardAddOrEdit("设备信息管理 / "+(model?"修改":"新增"),"ciis/equipment")
</div>
#end

###需要编辑的字段，默认展示了所有，需自己删除多余内容
#define cardCol()
    <input type="hidden" name="equipment.id" value="#(model.id??)">
    <div class="col-sm-6">
        <div class="form-group">
            <lable>企业</lable>
            <select name="equipment.name" class="select2">
                #for(x:enterpriseList)
                <option value="#(x.id)" #(model.name??==x.id?"selected":"")>#(x.name)</option>
                #end
            </select>
            <i class="form-group__bar"></i>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="form-group">
            <lable>名称</lable>
            <input type="text" class="form-control" name="equipment.name" value="#(model.name??)"
                   placeholder="请输入名称">
            <i class="form-group__bar"></i>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="form-group">
            <lable>IP地址</lable>
            <input type="text" class="form-control" name="equipment.ip" value="#(model.ip??)"
                   placeholder="请输入IP地址">
            <i class="form-group__bar"></i>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="form-group">
            <lable>端口</lable>
            <input type="text" class="form-control" name="equipment.port" value="#(model.port??)"
                   placeholder="请输入端口">
            <i class="form-group__bar"></i>
        </div>
    </div>
    <div class="col-sm-6">
        <div class="form-group">
            <lable>编号</lable>
            <input type="text" class="form-control" name="equipment.code" value="#(model.code??)"
                   placeholder="请输入编号">
            <i class="form-group__bar"></i>
        </div>
    </div>

#end
<!--无用的可以删除-->
<!--下拉框样式-->
<script>
    if ($("select.select2")[0]) {
        var a = $(".select2-parent")[0] ? $(".select2-parent") : $("body");
        $("select.select2").select2({
            dropdownAutoWidth: !0,
            width: "100%",
            dropdownParent: a
        })
    }
    /*时间选择器加载*/
    $(".datetime-picker")[0] && $(".datetime-picker").flatpickr({
        enableTime: !0,
        nextArrow: '<i class="zmdi zmdi-long-arrow-right" />',
        prevArrow: '<i class="zmdi zmdi-long-arrow-left" />'
    });

    $(".date-picker")[0] && $(".date-picker").flatpickr({
        enableTime: !1,
        nextArrow: '<i class="zmdi zmdi-long-arrow-right" />',
        prevArrow: '<i class="zmdi zmdi-long-arrow-left" />',
    });

    $(".time-picker")[0] && $(".time-picker").flatpickr({
        noCalendar: !0,
        enableTime: !0
    });

    //过滤编辑页面
    if (window.location.href.indexOf("addOrEdit?id=") === -1) {
        var select = $("select");
        $.each(select, function (i, v) {
            var name = $(v).attr("name"), n = localStorage.getItem(name);
            if (n) {
                $("select[name='" + name + "'] option").eq(n).prop('selected', true);
            }
        })

        $("select").on('change', function () {
            var name = $(this).attr("name");
            localStorage.setItem(name, $('option:selected', this).index());
        });
    }
</script>